#include <bits/stdc++.h>
using namespace std;

int n,i,t,l,flat;
int a[100001]={0};
int ans[11]={0};


int main(){
	freopen("color.in","r",stdin);
	freopen("color.out","w",stdout);
	cin>>t;
	for(l=1;l<=t;l++){
		flat=0;
		cin>>n;
		for(i=1;i<=n;i++){
			cin>>a[i];
		}
		sort(a,a+n+1);
		for(i=1;i<=n;i++){
			if(a[i]!=flat) flat=a[i];
			else ans[l]+=a[i];
		}
	}
	for(i=1;i<=t;i++){
			cout<<ans[i]<<endl;
		}
	return 0;
}




